#include "stdafx.h"

struct Bar
{
    float current, height, width, period, inverse; // 0 to 1
    
    sf::Color
        border, empty, filled;
    sf::RectangleShape frame, progress;
	//Gorilla::Rectangle * frame, * progress;
    Bar()
    {
        border = Color(255,255,255,255);
        empty = Color(128, 128, 128, 32);
        filled = Color(196, 196, 196, 255);

        height = 10.0f;
        width = 100.0f;
        current = 0.f;

        progress = RectangleShape();
        frame = RectangleShape();

        progress.setPosition(10,10);
        frame.setPosition(10,10);
        progress.setFillColor(filled);

        frame.setOutlineThickness(2);
        frame.setOutlineColor(border);
        frame.setFillColor(empty);

        frame.setSize(Vector2f(width, height));
        progress.setSize(Vector2f(0, height));
    }
    void setPosition(float x, float y)
    {
        progress.setPosition(x,y);
        frame.setPosition(x,y);
    }
    void set_progress(float f)
    {
        if(f >= 0.0 && f <= 1.0f)
            progress.setSize(sf::Vector2f(width * f, height));//->width(frame->width() * f);

    }
    //void add_progress(float f)
    //{
    //    current += f;
    //    if(current > 1.f) 
    //        current -= 1.f;
    //    progress.setSize(sf::Vector2f(width * current, height));
    //}
    void add_time(float f)
    {
        current += f;
        if(current > period) 
            current -= period;
        progress.setSize(sf::Vector2f(width * current * inverse, height));
    }
};

